package com.ktwlsoft.archivemanage.controller.businessInspect;

import com.ktwlsoft.archivemanage.domain.business.businessService.businessInspect.BusinessInspectRecordService;
import com.ktwlsoft.archivemanage.domain.dao.entity.businessInspect.BusinessInspectRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;


/**
 * business_inspect_record--业务检查记录控制层
 *
 * @author zhuhe
 * @date 2023/06/26
 */
@Api(value = "业务检查记录控制层",description = "业务检查记录控制层",tags = "1.2")
@RestController
@RequestMapping(value = "businessInspectRecord")
@RequiredArgsConstructor
public class BusinessInspectRecordController {

    private final BusinessInspectRecordService service;

    /**
     * 获取业务检查记录 on 2019/11/7 10:27
     *
     * @param userId userId
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "获取业务检查记录")
    @ResponseBody
    @GetMapping("getBusinessInspectRecord")
    public ResponseEntity<?> getBusinessInspectRecord(@ApiParam(name = "userId", value = "用户id") @RequestParam(defaultValue = "") Long userId,
                                                      @ApiParam(name = "businessType", value = "类型:selfAdvice(自查意见),guidAdvice(检查意见(复查意见)),unitAdvice(被检查意见(确认意见))") @RequestParam(defaultValue = "") String businessType) {
        return ResponseEntity.ok(service.getBusinessInspectRecord(userId,businessType));
    }

    /**
     * 新增业务检查记录 on 2019/11/7 10:27
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "新增业务检查记录")
    @ResponseBody
    @PostMapping("save")
    public ResponseEntity<?> save(@RequestBody BusinessInspectRecord record) {
        return ResponseEntity.ok(service.save(record));
    }

    /**
     * 编辑业务检查记录 on 2019/11/7 10:27
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "编辑业务检查记录")
    @ResponseBody
    @PostMapping("edit")
    public ResponseEntity<?> edit(@RequestBody BusinessInspectRecord record) {
        return ResponseEntity.ok(service.edit(record));
    }

    /**
     * 删除业务检查记录 on 2019/11/7 10:27
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "删除业务检查记录")
    @ResponseBody
    @GetMapping("delete")
    public ResponseEntity<?> delete(@ApiParam(name = "id", value = "记录id") @RequestParam(defaultValue = "") String id) {
        return ResponseEntity.ok(service.delete(id));
    }

    /**
     * 启用禁用 on 2019/11/7 10:27
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "启用禁用")
    @ResponseBody
    @GetMapping("editStatus")
    public ResponseEntity<?> editStatus(@ApiParam(name = "id", value = "记录id") @RequestParam(defaultValue = "") String id) {
        return ResponseEntity.ok(service.editStatus(id));
    }

    /**
     * 分页 on 2019/11/7 10:27
     *
     * @return ResponseEntity<?>
     */
    @ApiOperation(value = "分页")
    @ResponseBody
    @GetMapping("findPage")
    public ResponseEntity<?> findPage(@RequestParam(defaultValue = "1") int pn,
                                      @RequestParam(defaultValue = "30") int ps,
                                      @ApiParam(name = "userId", value = "用户id") @RequestParam(defaultValue = "") Long userId,
                                      @ApiParam(name = "businessType", value = "类型:selfAdvice(自查意见),guidAdvice(检查意见(复查意见)),unitAdvice(被检查意见(确认意见))") @RequestParam(defaultValue = "") String businessType) {
        return ResponseEntity.ok(service.findPage(pn,ps,userId,businessType));
    }
}
